<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组 Const</title>
</head>
<body>
<h2>无法重新赋值</h2>
<p>用 const 声明的数组不能重新赋值：</p>
<p id="demo"></p>

<script>
  try {
    const cars = ["Saab", "Volvo", "BMW"];
    cars = ["Toyota", "Volvo", "Audi"];
  }
  catch (err) {
    document.getElementById("demo").innerHTML = err;
  }
</script>

</body>
</html>

<!--
运行结果：TypeError: Assignment to constant variable.
-->